package com.rock.upms.web.common.tags;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;
import com.rock.common.util.AESUtil;

public class IdCryptTag extends BodyTagSupport {
	private static final long serialVersionUID = -1024509989705441700L;
	Object idString;
	String pass;

	public int doStartTag() throws JspException {
		JspWriter out = this.pageContext.getOut();
		if (this.idString == null) {
			return 0;
		}
		try {
			String reviceString = null;
			if ((this.idString instanceof Long)) {
				reviceString = ((Long) this.idString).toString();
			} else if ((this.idString instanceof String)) {
				reviceString = (String) this.idString;
			} else if ((this.idString instanceof Integer)) {
				reviceString = ((Integer) this.idString).toString();
			} else {
				reviceString = this.idString.toString();
			}
			out.print(AESUtil.getInstance().encrypt(this.pass, reviceString));
		} catch (IOException e) {
			throw new JspException(e);
		}
		return 6;
	}

	public Object getIdString() {
		return this.idString;
	}

	public void setIdString(Object idString) {
		this.idString = idString;
	}

	public String getPass() {
		return this.pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}
}
